

package com.hex.ds.code.detection.config.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hex.ds.code.detection.config.model.ConfigPropertyJdbcconfig;
import com.hex.ds.code.detection.common.annotation.AnonymousAccess;
import org.springframework.http.ResponseEntity;
import com.hex.ds.code.detection.config.service.ConfigPropertyJdbcconfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * jdbc配置表
 *
 * @author zl
 * @date 2024-02-05 10:07:09
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/configpropertyjdbcconfig" )
@Api(value = "configpropertyjdbcconfig", tags = "jdbc配置表管理")
public class ConfigPropertyJdbcconfigController {

    private final  ConfigPropertyJdbcconfigService configPropertyJdbcconfigService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param configPropertyJdbcconfig jdbc配置表
     * WrapperEnhancer.like(configPropertyJdbcconfig); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @AnonymousAccess
    public ResponseEntity<Object> getConfigPropertyJdbcconfigPage(Page page, ConfigPropertyJdbcconfig configPropertyJdbcconfig) {
        return ResponseEntity.ok(configPropertyJdbcconfigService.queryList(page,configPropertyJdbcconfig));
    }


    /**
     * 通过id查询jdbc配置表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @AnonymousAccess
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(configPropertyJdbcconfigService.getById(id));
    }

    /**
     * 新增jdbc配置表
     * @param configPropertyJdbcconfig jdbc配置表
     * @return R
     */
    @ApiOperation(value = "新增jdbc配置表", notes = "新增jdbc配置表")
    @PostMapping
    @AnonymousAccess
    public ResponseEntity<Object> save(@RequestBody ConfigPropertyJdbcconfig configPropertyJdbcconfig) {
        return ResponseEntity.ok(configPropertyJdbcconfigService.save(configPropertyJdbcconfig));
    }

    /**
     * 修改jdbc配置表
     * @param configPropertyJdbcconfig jdbc配置表
     * @return R
     */
    @ApiOperation(value = "修改jdbc配置表", notes = "修改jdbc配置表")
    @PutMapping
    @AnonymousAccess
    public ResponseEntity<Object> updateById(@RequestBody ConfigPropertyJdbcconfig configPropertyJdbcconfig) {
        return ResponseEntity.ok(configPropertyJdbcconfigService.updateById(configPropertyJdbcconfig));
    }

    /**
     * 通过id删除jdbc配置表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除jdbc配置表", notes = "通过id删除jdbc配置表")
    @DeleteMapping("/{id}" )
    @AnonymousAccess
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(configPropertyJdbcconfigService.removeById(id));
    }

    /**
     * 测试连接方法
     * @return R
     */
    @ApiOperation(value = "测试连接方法", notes = "测试连接方法")
    @PostMapping("/connectTest" )
    @AnonymousAccess
    public ResponseEntity<Object> connectTest(@RequestBody ConfigPropertyJdbcconfig configPropertyJdbcconfig) {
        return ResponseEntity.ok(configPropertyJdbcconfigService.connectTest(configPropertyJdbcconfig));
    }
}
